
import axios from "axios"

import { getroutes } from "../../store/userinfo"

import { useDispatch } from "react-redux"
let account = ""
let password = ""



function Login(){

    let dispatch = useDispatch()

    const login = ()=>{
        console.log(account,password)
        axios.post("http://192.168.137.1:8001/login",{Account:account,Password:password}).then((res)=>{
            if(res.data.msg === "success"){
                localStorage.setItem("id",res.data.id)
                dispatch(getroutes(res.data.id))
            }
        })
    }

    return <>
        <div>账号: <input type="text" onInput={(e)=>{account = e.target.value}}></input></div>
        <div>密码: <input type="number" onInput={(e)=>{password = e.target.value}}></input></div>
        <br/>
        <div> <button onClick={login}>登录</button></div>
    </>
}

export default Login